#include "iso_static.h"

#include "tools.h"

staticSprite::staticSprite(const int posX, const int posY, const bn::sprite_item& spriteItem, const int collisionWidth, const int collisionHeight, const int spriteHeight)
    : sprite{posX, posY, spriteItem}
    , collisionRect{posX-collisionWidth/2, posY+spriteHeight/2, collisionWidth, spriteHeight}
    , spriteRect{posX, posY, spriteHeight, spriteHeight}
    , spriteHeight{spriteHeight}
{

}

bn::fixed_rect staticSprite::getCollisionRect()
{
    return collisionRect;
}

bn::fixed_rect staticSprite::getSpriteRect()
{
    return spriteRect;
}

void staticSprite::setCollisionRect(const bn::fixed& x, const bn::fixed& y)
{
    collisionRect = bn::fixed_rect{x-collisionRect.width().integer()/2,y+spriteHeight/2,collisionRect.width(), collisionRect.height()};
    spriteRect = bn::fixed_rect{x,y,spriteRect.width(), spriteRect.height()};
}

int staticSprite::getSpriteHeight()
{
    return spriteHeight;
}

void staticSprite::setX(const int x)
{
    currentPosX = x;
    collisionRect.set_x(currentPosX-collisionRect.width().integer()/2);
    spriteRect.set_x(currentPosX);
}

void staticSprite::setY(const int y)
{
    currentPosY = y;
    collisionRect.set_y(currentPosY+spriteHeight/2);
    spriteRect.set_y(currentPosY);
}

void staticSprite::draw()
{
    spritePtr.set_position(tool::convert2dToScreenPoint(currentPosX, currentPosY, collisionRect.width().integer(), collisionRect.height().integer()));
}

void staticSprite::update()
{

}
